package com.etpjava.service.impl;

import java.util.List;
import java.util.Map;

import com.etpjava.dao.EmployeeDao;
import com.etpjava.model.Employee;
import com.etpjava.service.EmployeeService;
import com.etpjava.util.Page;

/**
 * @author liuk
 * @version 0.0.1
 * @see EmployeeService
 * impl of EmployeeService
 *
 */
public class EmployeeServiceImpl implements EmployeeService {
 private	EmployeeDao emdao;

	public EmployeeDao getEmdao() {
	return emdao;
}

public void setEmdao(EmployeeDao emdao) {
	this.emdao = emdao;
}

	@Override
	public List<Employee> findAll() {

		return emdao.findAll();
	}

	@Override
	public void findAll(Page p) {

		emdao.findAll(p);
	}

	@Override
	public void delete(int id) {
		Employee em = emdao.findById(id);
		emdao.delete(em);

	}

	@Override
	public void deleteMore(int[] ids) {
		for (int id : ids) {
			Employee em = emdao.findById(id);
			emdao.delete(em);
		}

	}

	@Override
	public boolean add(Employee em) {
	return	emdao.save(em);

	}

	@Override
	public void modify(Employee em) {
		emdao.update(em);

	}

	@Override
	public Employee findById(int id) {

		return emdao.findById(id);
	}

	@Override
	public void  findByName(Page p,String name) {
		emdao.findByName(p,name);
	}

	@Override
	public List<Employee>findByPhone(String phone) {
		// TODO Auto-generated method stub
		return emdao.findByPhone(phone);
	}

	public void search(Page p, Map<String, String> sw) {
		emdao.search(p,sw);
	}





}
